#include "UserLoginWidget.h"
#include "ui_UserLoginWidget.h"

#include <QMessageBox>
#include <QString>
#include "StudentManagerWidget.h"

UserLoginWidget::UserLoginWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::UserLoginWidget)
{
    ui->setupUi(this);

    ui->lineEdit_password->setPlaceholderText("请输入密码：");
    connect(ui->pushButton_Login,SIGNAL(clicked()),this,SLOT(on_pushButton_Login_clicked()));

    //this->setWindowFlag(Qt::FramelessWindowHint);

}

UserLoginWidget::~UserLoginWidget()
{
    delete ui;
}

void UserLoginWidget::paintEvent(QPaintEvent *event)
{
    QPainter painter(this);
    painter.drawPixmap(0,0,width(),height(),QPixmap(":/image/jiemian.png"));
}

void UserLoginWidget::on_pushButton_Login_clicked()
{
    QString name = ui->lineEdit_name->text();
    QString pswd = ui->lineEdit_password->text();

    if(name == "张三" && pswd == "123")
    {
        this->hide();
        m_mainWidget.showMaximized();
    }
    else
    {
        QMessageBox::information(nullptr,"提示",QString("用户名[%1]不存在,或密码错误").arg(name));
    }
}
